package com.example.telesys.handler;

import com.example.telesys.exception.TokenExpiredException;
import com.example.telesys.pojo.ApiResponse;
import com.example.telesys.pojo.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class TokenExpiredExceptionHandler {

    @ExceptionHandler(TokenExpiredException.class)
    @ResponseBody
    public ApiResponse TokenExpiredExceptionHandle(TokenExpiredException e) {
        return new ApiResponse(StatusCode.TOKEN_EXPIRED, e.getMessage(), null);
    }
}
